home *** CD-ROM | disk | FTP | other *** search
-
-
-
- RRRRWWWWCCCCLLLLIIIIPPPPssssttttrrrreeeeaaaammmmbbbbuuuuffff((((3333CCCC++++++++)))) RRRRWWWWCCCCLLLLIIIIPPPPssssttttrrrreeeeaaaammmmbbbbuuuuffff((((3333CCCC++++++++))))
-
-
-
- NNNNaaaammmmeeee
- RWCLIPstreambuf - Rogue Wave library class
-
- SSSSyyyynnnnooooppppssssiiiissss
- #include <rw/winstrea.h>
-
-
-
- #include <iostream.h>
- iostream str( new RWCLIPstreambuf() );
-
-
-
-
- DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
- Class RRRRWWWWCCCCLLLLIIIIPPPPssssttttrrrreeeeaaaammmmbbbbuuuuffff is a specialized ssssttttrrrreeeeaaaammmmbbbbuuuuffff that gets and puts
- sequences of characters to Microsoft Windows global memory. It can be
- used to exchange data through Windows clipboard facility. The class has
- two modes of operation: dynamic and static. In dynamic mode, memory is
- allocated and reallocated as needed. If too many characters are inserted
- into the internal buffer for its present size, then it will be resized
- and old characters copied over into any new memory as necessary. This is
- transparent to the user. It is expected that this mode would be used
- primarily for "insertions," iiii....eeee...., clipboard "cuts" and "copies." In
- static mode, the buffer streambuf is constructed from a specific piece of
- memory. No reallocations will be done. It is expected that this mode
- would be used primarily for "extractions," iiii....eeee...., clipboard "pastes." In
- dynamic mode, the RRRRWWWWCCCCLLLLIIIIPPPPssssttttrrrreeeeaaaammmmbbbbuuuuffff "owns" any allocated memory until the
- member function ssssttttrrrr(((()))) is called, which "freezes" the buffer and returns
- an unlocked Windows handle to it. The effect of any further insertions
- is undefined. Until ssssttttrrrr(((()))) has been called, it is the responsibility of
- the RRRRWWWWCCCCLLLLIIIIPPPPssssttttrrrreeeeaaaammmmbbbbuuuuffff destructor to free any allocated memory. After the
- call to ssssttttrrrr(((()))), it becomes the user's responsibility. In static mode, the
- user has the responsibility for freeing the memory handle. However,
- because the constructor locks and dereferences the handle, you should not
- free the memory until either the destructor or ssssttttrrrr(((()))) has been called,
- either of which will unlock the handle.
-
- PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
- None
-
- EEEExxxxaaaammmmpppplllleeee
- //Instructions: compile as a Windows program.
- //Run this program, then using your favorite text editor or word
- //processor, select paste and see the result!
- #include <rw/winstrea.h>
- #include <stdlib.h>
- #include <iostream.h>
- #include <windows.h>
- void postToClipboard(HWND owner);
- main()
- {
-
-
-
- PPPPaaaaggggeeee 1111
-
-
-
-
-
-
- RRRRWWWWCCCCLLLLIIIIPPPPssssttttrrrreeeeaaaammmmbbbbuuuuffff((((3333CCCC++++++++)))) RRRRWWWWCCCCLLLLIIIIPPPPssssttttrrrreeeeaaaammmmbbbbuuuuffff((((3333CCCC++++++++))))
-
-
-
- postToClipboard(NULL);
- return 0;
- }
- // PASS YOUR WINDOW HANDLE TO THIS FUNCTION THEN PASS YOUR VALUES
- // TO THE CLIPBOARD USING ostr.
- void postToClipboard(HWND owner)
- {
- //Build the clipstream buffer on the heap
- RWCLIPstreambuf* buf = new
- RWCLIPstreambuf();
- ostream ostr(buf);
- double d = 12.34;
- ostr << "Some text to be exchanged through the clipboard.0;
- ostr << "Might as well add a double: " << d << endl;
- ostr.put(' '); // Include the terminating null
- // Lock the streambuf, get its handle:
- HANDLE hMem = buf->str();
- OpenClipboard(owner);
- EmptyClipboard();
- SetClipboardData(CF_TEXT, hMem);
- CloseClipboard();
-
- // Don't delete the buffer!. Windows is now responsible for it.
- }
-
-
- The owner of the clipboard is passed in as parameter "oooowwwwnnnneeeerrrr". A
- conventional oooossssttttrrrreeeeaaaammmm is created, except that it uses an RRRRWWWWCCCCLLLLIIIIPPPPssssttttrrrreeeeaaaammmmbbbbuuuuffff
- as its associated ssssttttrrrreeeeaaaammmmbbbbuuuuffff. It can be used much like any other oooossssttttrrrreeeeaaaammmm,
- such as ccccoooouuuutttt, except that characters will be inserted into Windows global
- memory. Some text and a double is inserted into the oooossssttttrrrreeeeaaaammmm. Finally,
- member function ssssttttrrrr(((()))) is called which returns a Windows HHHHAAAANNNNDDDDLLLLEEEE. The
- clipboard is then opened, emptied, and the new data put into it with
- format CCCCFFFF____TTTTEEEEXXXXTTTT which, in this case, is appropriate because a simple
- oooossssttttrrrreeeeaaaammmm was used to format the output. If a specializing virtual streams
- class such as RRRRWWWWbbbboooossssttttrrrreeeeaaaammmm or RRRRWWWWppppoooossssttttrrrreeeeaaaammmm had been used instead, the format
- is not so simple. In this case, the user might want to register his or
- her own format, using the Windows function RRRReeeeggggiiiisssstttteeeerrrrCCCClllliiiippppbbbbooooaaaarrrrddddFFFFoooorrrrmmmmaaaatttt(((()))).
-
- PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss
- RRRRWWWWCCCCLLLLIIIIPPPPssssttttrrrreeeeaaaammmmbbbbuuuuffff();
-
-
- Constructs an empty RRRRWWWWCCCCLLLLIIIIPPPPssssttttrrrreeeeaaaammmmbbbbuuuuffff in dynamic mode. The results can be
- used anywhere any other ssssttttrrrreeeeaaaammmmbbbbuuuuffff can be used. Memory to accomodate new
- characters will be allocated as needed.
-
- RRRRWWWWCCCCLLLLIIIIPPPPssssttttrrrreeeeaaaammmmbbbbuuuuffff(HANDLE hMem);
-
-
- Constructs an RRRRWWWWCCCCLLLLIIIIPPPPssssttttrrrreeeeaaaammmmbbbbuuuuffff in static mode, using the memory block with
- global handle hhhhMMMMeeeemmmm. The effect of ggggeeeettttssss and ppppuuuuttttssss beyond the size of this
-
-
-
- PPPPaaaaggggeeee 2222
-
-
-
-
-
-
- RRRRWWWWCCCCLLLLIIIIPPPPssssttttrrrreeeeaaaammmmbbbbuuuuffff((((3333CCCC++++++++)))) RRRRWWWWCCCCLLLLIIIIPPPPssssttttrrrreeeeaaaammmmbbbbuuuuffff((((3333CCCC++++++++))))
-
-
-
- memory block is unspecified.
-
- PPPPuuuubbbblllliiiicccc DDDDeeeessssttttrrrruuuuccccttttoooorrrr
- ~RRRRWWWWCCCCLLLLIIIIPPPPssssttttrrrreeeeaaaammmmbbbbuuuuffff();
-
-
- If member function ssssttttrrrr(((()))) has not been called, the destructor unlocks the
- handle and, if in dynamic mode, also frees it.
-
- PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
-
-
-
- Because RRRRWWWWCCCCLLLLIIIIPPPPssssttttrrrreeeeaaaammmmbbbbuuuuffff inherits from ssssttttrrrreeeeaaaammmmbbbbuuuuffff, any of the latter's
- member functions can be used. Furthermore, RRRRWWWWCCCCLLLLIIIIPPPPssssttttrrrreeeeaaaammmmbbbbuuuuffff has been
- designed to be analogous to ssssttttrrrrssssttttrrrreeeeaaaammmmbbbbuuuuffff. However, note that the return
- type of ssssttttrrrr(((()))) is a HHHHAAAANNNNDDDDLLLLEEEE, rather than a cccchhhhaaaarrrr****.
-
- HANDLE
- ssssttttrrrr();
-
-
- Returns an (unlocked) HHHHAAAANNNNDDDDLLLLEEEE to the global memory being used. The
- RRRRWWWWCCCCLLLLIIIIPPPPssssttttrrrreeeeaaaammmmbbbbuuuuffff should now be regarded as "frozen": the effect of
- inserting any more characters is undefined. If the RRRRWWWWCCCCLLLLIIIIPPPPssssttttrrrreeeeaaaammmmbbbbuuuuffff was
- constructed in dynamic mode, and nothing has been inserted, then the
- returned HHHHAAAANNNNDDDDLLLLEEEE may be NNNNUUUULLLLLLLL. If it was constructed in static mode, then
- the returned handle will be the handle used to construct the
- RRRRWWWWCCCCLLLLIIIIPPPPssssttttrrrreeeeaaaammmmbbbbuuuuffff.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PPPPaaaaggggeeee 3333
-
-
-
-